package com.hms.entity;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 * 角色实体类. <br>
 * 类详细说明.
 * <p>
 * Copyright: Copyright (c) 2013-3-29 下午2:05:57
 * <p>
 * Company: 北京宽连十方数字技术有限公司
 * <p>
 * 
 * @author wangpz@c-platform.com
 * @version 1.0.0
 */
@Entity
@Table(name = "td_role")
public class Role extends BaseEntity {

	/** serialVersionUID */
	private static final long serialVersionUID = -6062956270769815307L;

	/**
	 * 角色名称
	 */
	private String name;

	/**
	 * 角色标识
	 */
	private String value;

	/**
	 * 描述
	 */
	private String description;

	/**
	 * 是否为内置系统管理员
	 */
	private Boolean isSystem;

	/**
	 * 管理员
	 */
	private Set<Admin> adminSet;

	/**
	 * 资源
	 */
	private Set<Resource> resourceSet;

	@Column(name = "name", nullable = false, unique = true)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "value", nullable = false, unique = true)
	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	@Column(name = "description")
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name = "isSystem")
	public Boolean getIsSystem() {
		return isSystem;
	}

	public void setIsSystem(Boolean isSystem) {
		this.isSystem = isSystem;
	}

	@ManyToMany(fetch = FetchType.LAZY, mappedBy = "roleSet")
	public Set<Admin> getAdminSet() {
		return adminSet;
	}

	public void setAdminSet(Set<Admin> adminSet) {
		this.adminSet = adminSet;
	}

	@ManyToMany(fetch = FetchType.LAZY)
	public Set<Resource> getResourceSet() {
		return resourceSet;
	}

	public void setResourceSet(Set<Resource> resourceSet) {
		this.resourceSet = resourceSet;
	}

	@Transient
	public Boolean isSystem() {
		return !this.isSystem;
	}

}
